package com.feng.cloud.common.configure;

import com.feng.cloud.common.aspect.IdempotentAspect;
import com.feng.cloud.common.expression.ExpressionResolver;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName IdempotentAutoConfigure
 * @Description TODO
 * @Author Better Feng
 * @Date 2021/1/21 17:37
 **/
@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter(RedisAutoConfiguration.class)
public class IdempotentAutoConfigure {

    /**
     * 切面 拦截处理所有 @Idempotent
     * @return IdempotentAspect
     */
    @Bean
    public IdempotentAspect idempotentAspect() {
        return new IdempotentAspect();
    }

    /**
     * key 解析器
     * @return ExpressionResolver
     */
    @Bean
    @ConditionalOnMissingBean(ExpressionResolver.class)
    public ExpressionResolver expressionResolver() {
        return new ExpressionResolver();
    }

}
